//
//  Status.swift
//  01-WeiBo
//
//  Created by 李晓东 on 17/7/7.
//  Copyright © 2017年 PeanutXu. All rights reserved.
//

import UIKit

class Status: NSObject {

    /// 微博ID
    var id: Int = 0
    /// 微博信息内容
    var text: String?
    /// 微博创建时间
    var created_at: String?
    /// 微博来源
    var source: String?
    /// 缩略图配图数组 key: thumbnail_pic
    var pic_urls: [[String: String]]?
    /// 用户模型
    var user: User?
    
    init(dict:[String: AnyObject]) {
        super.init()
        setValuesForKeys(dict)
    }
    
    override func setValue(_ value: Any?, forKey key: String) {
        if key == "user" {
            if let dict = value as? [String: AnyObject] {
                let user = User(dict: dict)
                self.user = user
                return
            }
            
            super.setValue(value, forKey: key)
            return
        }
        
        super.setValue(value, forKey: key)
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
    }
    
    override var description: String{
        let key = ["id", "text", "created_at", "source", "pic_urls"]
        
        return dictionaryWithValues(forKeys: key).description
    }
}
